<!--
    * Time    : 2021-03-11 13:43:17
    * Author  : zhangTj
    * Desc    : 日期组件
-->

<template>
    <div class="p-15p">
        <div class="font-14">
            <span class="text-danger" v-if="value.required">*</span>
            {{ index + 1 }}.{{ value.title || '标题' }}
        </div>
        <div class="py-1">
            <div @click="showDate = true" class="d-flex a-center bg-fff" style="height: 40px; padding: 0 17px">
                <span v-if="!value.content" class="flex-1 font-15" style="color: #c8c9cc">请选择</span>
                <span v-else class="flex-1 font-14">{{ value.content | dateformat('YYYY-MM-DD') }}</span>
                <i class="iconfont iconArrowRight" style="font-size: 14px"></i>
            </div>
        </div>
        <van-popup v-model="showDate" position="bottom" :style="{ height: '50%' }">
            <van-datetime-picker v-model="value.content" @confirm="confirmDate" type="date" title="选择年月日" :min-date="minDate" />
        </van-popup>
    </div>
</template>

<script>
export default {
    name: 'TextInput',
    props: {
        index: {
            type: Number | String,
            default: 0
        },
        value: Object
    },
    computed: {
        inputType() {}
    },
    data() {
        return {
            showDate: false,
            minDate: new Date(1970, 0, 1),
            currentDate: new Date()
        }
    },
    methods: {
        // 确定时间
        confirmDate(date) {
            this.value.content = new Date(date).getTime() 
            this.showDate = false
        
        }
    }
}
</script>

<style lang="scss" scoped></style>
